package com.zhuoshi.demo;

import java.io.IOException;
import java.io.InputStream;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Before;
import org.junit.Test;

import com.zhuoshi.bean.People;
import com.zhuoshi.bean.Person;

public class Mydemo {
	SqlSessionFactory factory;
	@Before
	public void before() throws IOException{
		//   org/mybatis/example/mybatis-config.xml
		String resource = "sqlMapConfig.xml";
		InputStream inputStream = Resources.getResourceAsStream(resource);
		 factory = new SqlSessionFactoryBuilder().build(inputStream);
	    
	}
	
	@Test
   public void selectPeople(){
		SqlSession session = factory.openSession();
	    String str ="com.zhuoshi.bean.PeopleMapper.selectPeople";
		People one = session.selectOne(str, 1); 
		System.out.println(one);
	}
	@Test
	   public void selectPerson(){
			SqlSession session = factory.openSession();
		    String str ="com.zhuoshi.bean.PersonMapper.selectName";
			String one = session.selectOne(str, 1); 
			System.out.println(one);
		}
   }
